package me.zhengjie.controller;


import me.zhengjie.server.InboundService;
import me.zhengjie.vo.Inbound.MesMaterialVo;
import me.zhengjie.vo.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


@RestController
@RequestMapping("wms/inbound")
public class InboundController {

    private static final Logger inboundLog = LoggerFactory.getLogger("inbound");

    @Resource
    private InboundService inboundService;

    @RequestMapping(value = "/storageApply", method = RequestMethod.POST)
    @ResponseBody
    public Result<String> InboundStorageApply(@RequestBody MesMaterialVo mesMaterialVo)  {
        System.out.println(mesMaterialVo);
        long start = System.currentTimeMillis();
        inboundLog.info("入库申请接口");
        Result<String> stringResult = inboundService.InboundStorageApply(mesMaterialVo);
        System.out.println(stringResult.getData());
        long end = System.currentTimeMillis();
        System.out.println("入库申请接口耗时：" + (end - start) + "ms");
        return stringResult;
    }

    @RequestMapping(value = "/isCodeExist", method = RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> findContainerCodeIsExist(@RequestBody Map<String, Object> request) {
        inboundLog.info("查询库存是否存在载具");
        return inboundService.findContainerCodeIsExist(request);
    }

    @RequestMapping(value = "/revokeApply", method = RequestMethod.POST)
    @ResponseBody
    public Result<?> revokeStorageApply(@RequestBody Map<String, Object> request) {
        inboundLog.info("撤销储位申请");
        return inboundService.revokeStorageApply(request);
    }


}
